package com.jf.yytgd.validation.validator;

import com.jf.yytgd.validation.constrain.VisibleCharacter;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * Created with IntelliJ IDEA
 * Description: VisibleCharacter验证逻辑实现
 * User:22954
 * Date:2025-01-14
 * Time:11:02
 */
public class VisibleCharacterValidator implements ConstraintValidator<VisibleCharacter, String> {
    private static final String regex = "[^\\p{Cntrl}\\s]+";
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null) {
            return false;
        }
        return value.matches(regex);
    }
}
